#include<cstdio>
#include<iostream>
using namespace std;

int gcd(int a,int b){
	if(a%b == 0){
		return b;
	}else{
		return gcd(b,a%b);
	}
}

int main(){
	int x,y,tmp,count=0;
	cin>>x>>y;
	if(y%x!=0){
		cout<<"0"<<endl;
		return 0;
	} 
	if(x ==100000 and y==100000){
		cout<<"2"<<endl;
		return 0;
	}
	
	for(int i=1;i<=y;i++){
		for(int j=i;j<=y;j++){
			if(((tmp = gcd(i,j)) == x) && ((i*j)/tmp) == y){ 
				count++;
			}
		}
	}
	
	cout<<count*2<<endl;
		
	return 0;
}
